#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int finalPositionOfSnake(int n, char** commands, int commandsSize)
{
    int i = 0;
    int j = 0;
    for (int k = 0; k < commandsSize; k++)
    {
        char c = commands[k][0];
        if (c == 'U')
            i--;
        else if (c == 'D')
            i++;
        else if (c == 'R')
            j++;
        if (c == 'L')
            j--;
    }
    return i * n + j;
}